﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using PPWMS.DBUtility;
using PPWMS.Model;
namespace PPWMS.DAL
{
    /// <summary>
    /// 数据访问类:OPLog
    /// </summary>
    public partial class OPLog
    {
        public OPLog()
        { }
        #region  BasicMethod

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string Barcode)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from tb_OPLog");
            strSql.Append(" where Barcode=@Barcode ");
            SqlParameter[] parameters = {
					new SqlParameter("@Barcode", SqlDbType.VarChar,50)			};
            parameters[0].Value = Barcode;

            return SQLHelper.Exists(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(PPWMS.Model.OPLogModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into tb_OPLog(");
            strSql.Append("Barcode,SubPackNum,BoxId,OrderSubId,OrderId,ProdType,SailingDate,Destination,OutPlanDate,ProdSpeci,ProdDesc,Addi,FrameColor,LegType,MatchedInLeg,FootType,PanelSpeci,PanelFeature,PanelColor,BoardColor,BoardMaterial,EdgeColor,BackplaneColor,ChairType,ChairColor,SpecialTagsRemarks,IncludeItemsFlag,ItemsPerPack,OrderPackCount,TotalItemsCount,CheckedItemsCount,CompletedPackCount,LackedPackCount,PanelWeight,FrameWeight,Height,NetWeight,GrossWeight,Volume,AssemblyStation,SerialNum,PrintCount,PrintEmployeeNum,InEmployNum,OutEmployNum,State,PrintTime,InTime,OutTime,Remark)");
            strSql.Append(" values (");
            strSql.Append("@Barcode,@SubPackNum,@BoxId,@OrderSubId,@OrderId,@ProdType,@SailingDate,@Destination,@OutPlanDate,@ProdSpeci,@ProdDesc,@Addi,@FrameColor,@LegType,@MatchedInLeg,@FootType,@PanelSpeci,@PanelFeature,@PanelColor,@BoardColor,@BoardMaterial,@EdgeColor,@BackplaneColor,@ChairType,@ChairColor,@SpecialTagsRemarks,@IncludeItemsFlag,@ItemsPerPack,@OrderPackCount,@TotalItemsCount,@CheckedItemsCount,@CompletedPackCount,@LackedPackCount,@PanelWeight,@FrameWeight,@Height,@NetWeight,@GrossWeight,@Volume,@AssemblyStation,@SerialNum,@PrintCount,@PrintEmployeeNum,@InEmployNum,@OutEmployNum,@State,@PrintTime,@InTime,@OutTime,@Remark)");
            SqlParameter[] parameters = {
					new SqlParameter("@Barcode", SqlDbType.VarChar,50),
					new SqlParameter("@SubPackNum", SqlDbType.Int,4),
					new SqlParameter("@BoxId", SqlDbType.VarChar,50),
					new SqlParameter("@OrderSubId", SqlDbType.VarChar,50),
					new SqlParameter("@OrderId", SqlDbType.VarChar,50),
					new SqlParameter("@ProdType", SqlDbType.NVarChar,50),
					new SqlParameter("@SailingDate", SqlDbType.Date,3),
					new SqlParameter("@Destination", SqlDbType.NVarChar,500),
					new SqlParameter("@OutPlanDate", SqlDbType.Date,3),
					new SqlParameter("@ProdSpeci", SqlDbType.NVarChar,50),
					new SqlParameter("@ProdDesc", SqlDbType.NVarChar,-1),
					new SqlParameter("@Addi", SqlDbType.NVarChar,50),
					new SqlParameter("@FrameColor", SqlDbType.NVarChar,50),
					new SqlParameter("@LegType", SqlDbType.NVarChar,50),
					new SqlParameter("@MatchedInLeg", SqlDbType.NVarChar,50),
					new SqlParameter("@FootType", SqlDbType.NVarChar,50),
					new SqlParameter("@PanelSpeci", SqlDbType.NVarChar,50),
					new SqlParameter("@PanelFeature", SqlDbType.NVarChar,50),
					new SqlParameter("@PanelColor", SqlDbType.NVarChar,50),
					new SqlParameter("@BoardColor", SqlDbType.NVarChar,50),
					new SqlParameter("@BoardMaterial", SqlDbType.NVarChar,50),
					new SqlParameter("@EdgeColor", SqlDbType.NVarChar,50),
					new SqlParameter("@BackplaneColor", SqlDbType.NVarChar,50),
					new SqlParameter("@ChairType", SqlDbType.NVarChar,50),
					new SqlParameter("@ChairColor", SqlDbType.NVarChar,50),
					new SqlParameter("@SpecialTagsRemarks", SqlDbType.NVarChar,500),
					new SqlParameter("@IncludeItemsFlag", SqlDbType.Int,4),
					new SqlParameter("@ItemsPerPack", SqlDbType.Int,4),
					new SqlParameter("@OrderPackCount", SqlDbType.Int,4),
					new SqlParameter("@TotalItemsCount", SqlDbType.Int,4),
					new SqlParameter("@CheckedItemsCount", SqlDbType.Int,4),
					new SqlParameter("@CompletedPackCount", SqlDbType.Int,4),
					new SqlParameter("@LackedPackCount", SqlDbType.Int,4),
					new SqlParameter("@PanelWeight", SqlDbType.Decimal,9),
					new SqlParameter("@FrameWeight", SqlDbType.Decimal,9),
					new SqlParameter("@Height", SqlDbType.Int,4),
					new SqlParameter("@NetWeight", SqlDbType.Decimal,9),
					new SqlParameter("@GrossWeight", SqlDbType.Decimal,9),
					new SqlParameter("@Volume", SqlDbType.Decimal,9),
					new SqlParameter("@AssemblyStation", SqlDbType.VarChar,50),
					new SqlParameter("@SerialNum", SqlDbType.VarChar,50),
					new SqlParameter("@PrintCount", SqlDbType.Int,4),
					new SqlParameter("@PrintEmployeeNum", SqlDbType.VarChar,50),
					new SqlParameter("@InEmployNum", SqlDbType.VarChar,50),
					new SqlParameter("@OutEmployNum", SqlDbType.VarChar,50),
					new SqlParameter("@State", SqlDbType.NVarChar,50),
					new SqlParameter("@PrintTime", SqlDbType.DateTime),
					new SqlParameter("@InTime", SqlDbType.DateTime),
					new SqlParameter("@OutTime", SqlDbType.DateTime),
					new SqlParameter("@Remark", SqlDbType.NVarChar,500)};
            parameters[0].Value = model.Barcode;
            parameters[1].Value = model.SubPackNum;
            parameters[2].Value = model.BoxId;
            parameters[3].Value = model.OrderSubId;
            parameters[4].Value = model.OrderId;
            parameters[5].Value = model.ProdType;
            parameters[6].Value = model.SailingDate;
            parameters[7].Value = model.Destination;
            parameters[8].Value = model.OutPlanDate;
            parameters[9].Value = model.ProdSpeci;
            parameters[10].Value = model.ProdDesc;
            parameters[11].Value = model.Addi;
            parameters[12].Value = model.FrameColor;
            parameters[13].Value = model.LegType;
            parameters[14].Value = model.MatchedInLeg;
            parameters[15].Value = model.FootType;
            parameters[16].Value = model.PanelSpeci;
            parameters[17].Value = model.PanelFeature;
            parameters[18].Value = model.PanelColor;
            parameters[19].Value = model.BoardColor;
            parameters[20].Value = model.BoardMaterial;
            parameters[21].Value = model.EdgeColor;
            parameters[22].Value = model.BackplaneColor;
            parameters[23].Value = model.ChairType;
            parameters[24].Value = model.ChairColor;
            parameters[25].Value = model.SpecialTagsRemarks;
            parameters[26].Value = model.IncludeItemsFlag;
            parameters[27].Value = model.ItemsPerPack;
            parameters[28].Value = model.OrderPackCount;
            parameters[29].Value = model.TotalItemsCount;
            parameters[30].Value = model.CheckedItemsCount;
            parameters[31].Value = model.CompletedPackCount;
            parameters[32].Value = model.LackedPackCount;
            parameters[33].Value = model.PanelWeight;
            parameters[34].Value = model.FrameWeight;
            parameters[35].Value = model.Height;
            parameters[36].Value = model.NetWeight;
            parameters[37].Value = model.GrossWeight;
            parameters[38].Value = model.Volume;
            parameters[39].Value = model.AssemblyStation;
            parameters[40].Value = model.SerialNum;
            parameters[41].Value = model.PrintCount;
            parameters[42].Value = model.PrintEmployeeNum;
            parameters[43].Value = model.InEmployNum;
            parameters[44].Value = model.OutEmployNum;
            parameters[45].Value = model.State;
            parameters[46].Value = model.PrintTime;
            parameters[47].Value = model.InTime;
            parameters[48].Value = model.OutTime;
            parameters[49].Value = model.Remark;

            int rows = SQLHelper.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(PPWMS.Model.OPLogModel model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update tb_OPLog set ");
            strSql.Append("SubPackNum=@SubPackNum,");
            strSql.Append("BoxId=@BoxId,");
            strSql.Append("OrderSubId=@OrderSubId,");
            strSql.Append("OrderId=@OrderId,");
            strSql.Append("ProdType=@ProdType,");
            strSql.Append("SailingDate=@SailingDate,");
            strSql.Append("Destination=@Destination,");
            strSql.Append("OutPlanDate=@OutPlanDate,");
            strSql.Append("ProdSpeci=@ProdSpeci,");
            strSql.Append("ProdDesc=@ProdDesc,");
            strSql.Append("Addi=@Addi,");
            strSql.Append("FrameColor=@FrameColor,");
            strSql.Append("LegType=@LegType,");
            strSql.Append("MatchedInLeg=@MatchedInLeg,");
            strSql.Append("FootType=@FootType,");
            strSql.Append("PanelSpeci=@PanelSpeci,");
            strSql.Append("PanelFeature=@PanelFeature,");
            strSql.Append("PanelColor=@PanelColor,");
            strSql.Append("BoardColor=@BoardColor,");
            strSql.Append("BoardMaterial=@BoardMaterial,");
            strSql.Append("EdgeColor=@EdgeColor,");
            strSql.Append("BackplaneColor=@BackplaneColor,");
            strSql.Append("ChairType=@ChairType,");
            strSql.Append("ChairColor=@ChairColor,");
            strSql.Append("SpecialTagsRemarks=@SpecialTagsRemarks,");
            strSql.Append("IncludeItemsFlag=@IncludeItemsFlag,");
            strSql.Append("ItemsPerPack=@ItemsPerPack,");
            strSql.Append("OrderPackCount=@OrderPackCount,");
            strSql.Append("TotalItemsCount=@TotalItemsCount,");
            strSql.Append("CheckedItemsCount=@CheckedItemsCount,");
            strSql.Append("CompletedPackCount=@CompletedPackCount,");
            strSql.Append("LackedPackCount=@LackedPackCount,");
            strSql.Append("PanelWeight=@PanelWeight,");
            strSql.Append("FrameWeight=@FrameWeight,");
            strSql.Append("Height=@Height,");
            strSql.Append("NetWeight=@NetWeight,");
            strSql.Append("GrossWeight=@GrossWeight,");
            strSql.Append("Volume=@Volume,");
            strSql.Append("AssemblyStation=@AssemblyStation,");
            strSql.Append("SerialNum=@SerialNum,");
            strSql.Append("PrintCount=@PrintCount,");
            strSql.Append("PrintEmployeeNum=@PrintEmployeeNum,");
            strSql.Append("InEmployNum=@InEmployNum,");
            strSql.Append("OutEmployNum=@OutEmployNum,");
            strSql.Append("State=@State,");
            strSql.Append("PrintTime=@PrintTime,");
            strSql.Append("InTime=@InTime,");
            strSql.Append("OutTime=@OutTime,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where Barcode=@Barcode ");
            SqlParameter[] parameters = {
					new SqlParameter("@SubPackNum", SqlDbType.Int,4),
					new SqlParameter("@BoxId", SqlDbType.VarChar,50),
					new SqlParameter("@OrderSubId", SqlDbType.VarChar,50),
					new SqlParameter("@OrderId", SqlDbType.VarChar,50),
					new SqlParameter("@ProdType", SqlDbType.NVarChar,50),
					new SqlParameter("@SailingDate", SqlDbType.Date,3),
					new SqlParameter("@Destination", SqlDbType.NVarChar,500),
					new SqlParameter("@OutPlanDate", SqlDbType.Date,3),
					new SqlParameter("@ProdSpeci", SqlDbType.NVarChar,50),
					new SqlParameter("@ProdDesc", SqlDbType.NVarChar,-1),
					new SqlParameter("@Addi", SqlDbType.NVarChar,50),
					new SqlParameter("@FrameColor", SqlDbType.NVarChar,50),
					new SqlParameter("@LegType", SqlDbType.NVarChar,50),
					new SqlParameter("@MatchedInLeg", SqlDbType.NVarChar,50),
					new SqlParameter("@FootType", SqlDbType.NVarChar,50),
					new SqlParameter("@PanelSpeci", SqlDbType.NVarChar,50),
					new SqlParameter("@PanelFeature", SqlDbType.NVarChar,50),
					new SqlParameter("@PanelColor", SqlDbType.NVarChar,50),
					new SqlParameter("@BoardColor", SqlDbType.NVarChar,50),
					new SqlParameter("@BoardMaterial", SqlDbType.NVarChar,50),
					new SqlParameter("@EdgeColor", SqlDbType.NVarChar,50),
					new SqlParameter("@BackplaneColor", SqlDbType.NVarChar,50),
					new SqlParameter("@ChairType", SqlDbType.NVarChar,50),
					new SqlParameter("@ChairColor", SqlDbType.NVarChar,50),
					new SqlParameter("@SpecialTagsRemarks", SqlDbType.NVarChar,500),
					new SqlParameter("@IncludeItemsFlag", SqlDbType.Int,4),
					new SqlParameter("@ItemsPerPack", SqlDbType.Int,4),
					new SqlParameter("@OrderPackCount", SqlDbType.Int,4),
					new SqlParameter("@TotalItemsCount", SqlDbType.Int,4),
					new SqlParameter("@CheckedItemsCount", SqlDbType.Int,4),
					new SqlParameter("@CompletedPackCount", SqlDbType.Int,4),
					new SqlParameter("@LackedPackCount", SqlDbType.Int,4),
					new SqlParameter("@PanelWeight", SqlDbType.Decimal,9),
					new SqlParameter("@FrameWeight", SqlDbType.Decimal,9),
					new SqlParameter("@Height", SqlDbType.Int,4),
					new SqlParameter("@NetWeight", SqlDbType.Decimal,9),
					new SqlParameter("@GrossWeight", SqlDbType.Decimal,9),
					new SqlParameter("@Volume", SqlDbType.Decimal,9),
					new SqlParameter("@AssemblyStation", SqlDbType.VarChar,50),
					new SqlParameter("@SerialNum", SqlDbType.VarChar,50),
					new SqlParameter("@PrintCount", SqlDbType.Int,4),
					new SqlParameter("@PrintEmployeeNum", SqlDbType.VarChar,50),
					new SqlParameter("@InEmployNum", SqlDbType.VarChar,50),
					new SqlParameter("@OutEmployNum", SqlDbType.VarChar,50),
					new SqlParameter("@State", SqlDbType.NVarChar,50),
					new SqlParameter("@PrintTime", SqlDbType.DateTime),
					new SqlParameter("@InTime", SqlDbType.DateTime),
					new SqlParameter("@OutTime", SqlDbType.DateTime),
					new SqlParameter("@Remark", SqlDbType.NVarChar,500),
					new SqlParameter("@Barcode", SqlDbType.VarChar,50)};
            parameters[0].Value = model.SubPackNum;
            parameters[1].Value = model.BoxId;
            parameters[2].Value = model.OrderSubId;
            parameters[3].Value = model.OrderId;
            parameters[4].Value = model.ProdType;
            parameters[5].Value = model.SailingDate;
            parameters[6].Value = model.Destination;
            parameters[7].Value = model.OutPlanDate;
            parameters[8].Value = model.ProdSpeci;
            parameters[9].Value = model.ProdDesc;
            parameters[10].Value = model.Addi;
            parameters[11].Value = model.FrameColor;
            parameters[12].Value = model.LegType;
            parameters[13].Value = model.MatchedInLeg;
            parameters[14].Value = model.FootType;
            parameters[15].Value = model.PanelSpeci;
            parameters[16].Value = model.PanelFeature;
            parameters[17].Value = model.PanelColor;
            parameters[18].Value = model.BoardColor;
            parameters[19].Value = model.BoardMaterial;
            parameters[20].Value = model.EdgeColor;
            parameters[21].Value = model.BackplaneColor;
            parameters[22].Value = model.ChairType;
            parameters[23].Value = model.ChairColor;
            parameters[24].Value = model.SpecialTagsRemarks;
            parameters[25].Value = model.IncludeItemsFlag;
            parameters[26].Value = model.ItemsPerPack;
            parameters[27].Value = model.OrderPackCount;
            parameters[28].Value = model.TotalItemsCount;
            parameters[29].Value = model.CheckedItemsCount;
            parameters[30].Value = model.CompletedPackCount;
            parameters[31].Value = model.LackedPackCount;
            parameters[32].Value = model.PanelWeight;
            parameters[33].Value = model.FrameWeight;
            parameters[34].Value = model.Height;
            parameters[35].Value = model.NetWeight;
            parameters[36].Value = model.GrossWeight;
            parameters[37].Value = model.Volume;
            parameters[38].Value = model.AssemblyStation;
            parameters[39].Value = model.SerialNum;
            parameters[40].Value = model.PrintCount;
            parameters[41].Value = model.PrintEmployeeNum;
            parameters[42].Value = model.InEmployNum;
            parameters[43].Value = model.OutEmployNum;
            parameters[44].Value = model.State;
            parameters[45].Value = model.PrintTime;
            parameters[46].Value = model.InTime;
            parameters[47].Value = model.OutTime;
            parameters[48].Value = model.Remark;
            parameters[49].Value = model.Barcode;

            int rows = SQLHelper.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(string Barcode)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from tb_OPLog ");
            strSql.Append(" where Barcode=@Barcode ");
            SqlParameter[] parameters = {
					new SqlParameter("@Barcode", SqlDbType.VarChar,50)			};
            parameters[0].Value = Barcode;

            int rows = SQLHelper.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 批量删除数据
        /// </summary>
        public bool DeleteList(string Barcodelist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from tb_OPLog ");
            strSql.Append(" where Barcode in (" + Barcodelist + ")  ");
            int rows = SQLHelper.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public PPWMS.Model.OPLogModel GetModel(string Barcode)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 Barcode,SubPackNum,BoxId,OrderSubId,OrderId,ProdType,SailingDate,Destination,OutPlanDate,ProdSpeci,ProdDesc,Addi,FrameColor,LegType,MatchedInLeg,FootType,PanelSpeci,PanelFeature,PanelColor,BoardColor,BoardMaterial,EdgeColor,BackplaneColor,ChairType,ChairColor,SpecialTagsRemarks,IncludeItemsFlag,ItemsPerPack,OrderPackCount,TotalItemsCount,CheckedItemsCount,CompletedPackCount,LackedPackCount,PanelWeight,FrameWeight,Height,NetWeight,GrossWeight,Volume,AssemblyStation,SerialNum,PrintCount,PrintEmployeeNum,InEmployNum,OutEmployNum,State,PrintTime,InTime,OutTime,Remark from tb_OPLog ");
            strSql.Append(" where Barcode=@Barcode ");
            SqlParameter[] parameters = {
					new SqlParameter("@Barcode", SqlDbType.VarChar,50)			};
            parameters[0].Value = Barcode;

            PPWMS.Model.OPLogModel model = new PPWMS.Model.OPLogModel();
            DataSet ds = SQLHelper.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public PPWMS.Model.OPLogModel DataRowToModel(DataRow row)
        {
            PPWMS.Model.OPLogModel model = new PPWMS.Model.OPLogModel();
            if (row != null)
            {
                if (row["Barcode"] != null)
                {
                    model.Barcode = row["Barcode"].ToString();
                }
                if (row["SubPackNum"] != null && row["SubPackNum"].ToString() != "")
                {
                    model.SubPackNum = int.Parse(row["SubPackNum"].ToString());
                }
                if (row["BoxId"] != null)
                {
                    model.BoxId = row["BoxId"].ToString();
                }
                if (row["OrderSubId"] != null)
                {
                    model.OrderSubId = row["OrderSubId"].ToString();
                }
                if (row["OrderId"] != null)
                {
                    model.OrderId = row["OrderId"].ToString();
                }
                if (row["ProdType"] != null)
                {
                    model.ProdType = row["ProdType"].ToString();
                }
                if (row["SailingDate"] != null && row["SailingDate"].ToString() != "")
                {
                    model.SailingDate = DateTime.Parse(row["SailingDate"].ToString());
                }
                if (row["Destination"] != null)
                {
                    model.Destination = row["Destination"].ToString();
                }
                if (row["OutPlanDate"] != null && row["OutPlanDate"].ToString() != "")
                {
                    model.OutPlanDate = DateTime.Parse(row["OutPlanDate"].ToString());
                }
                if (row["ProdSpeci"] != null)
                {
                    model.ProdSpeci = row["ProdSpeci"].ToString();
                }
                if (row["ProdDesc"] != null)
                {
                    model.ProdDesc = row["ProdDesc"].ToString();
                }
                if (row["Addi"] != null)
                {
                    model.Addi = row["Addi"].ToString();
                }
                if (row["FrameColor"] != null)
                {
                    model.FrameColor = row["FrameColor"].ToString();
                }
                if (row["LegType"] != null)
                {
                    model.LegType = row["LegType"].ToString();
                }
                if (row["MatchedInLeg"] != null)
                {
                    model.MatchedInLeg = row["MatchedInLeg"].ToString();
                }
                if (row["FootType"] != null)
                {
                    model.FootType = row["FootType"].ToString();
                }
                if (row["PanelSpeci"] != null)
                {
                    model.PanelSpeci = row["PanelSpeci"].ToString();
                }
                if (row["PanelFeature"] != null)
                {
                    model.PanelFeature = row["PanelFeature"].ToString();
                }
                if (row["PanelColor"] != null)
                {
                    model.PanelColor = row["PanelColor"].ToString();
                }
                if (row["BoardColor"] != null)
                {
                    model.BoardColor = row["BoardColor"].ToString();
                }
                if (row["BoardMaterial"] != null)
                {
                    model.BoardMaterial = row["BoardMaterial"].ToString();
                }
                if (row["EdgeColor"] != null)
                {
                    model.EdgeColor = row["EdgeColor"].ToString();
                }
                if (row["BackplaneColor"] != null)
                {
                    model.BackplaneColor = row["BackplaneColor"].ToString();
                }
                if (row["ChairType"] != null)
                {
                    model.ChairType = row["ChairType"].ToString();
                }
                if (row["ChairColor"] != null)
                {
                    model.ChairColor = row["ChairColor"].ToString();
                }
                if (row["SpecialTagsRemarks"] != null)
                {
                    model.SpecialTagsRemarks = row["SpecialTagsRemarks"].ToString();
                }
                if (row["IncludeItemsFlag"] != null && row["IncludeItemsFlag"].ToString() != "")
                {
                    model.IncludeItemsFlag = int.Parse(row["IncludeItemsFlag"].ToString());
                }
                if (row["ItemsPerPack"] != null && row["ItemsPerPack"].ToString() != "")
                {
                    model.ItemsPerPack = int.Parse(row["ItemsPerPack"].ToString());
                }
                if (row["OrderPackCount"] != null && row["OrderPackCount"].ToString() != "")
                {
                    model.OrderPackCount = int.Parse(row["OrderPackCount"].ToString());
                }
                if (row["TotalItemsCount"] != null && row["TotalItemsCount"].ToString() != "")
                {
                    model.TotalItemsCount = int.Parse(row["TotalItemsCount"].ToString());
                }
                if (row["CheckedItemsCount"] != null && row["CheckedItemsCount"].ToString() != "")
                {
                    model.CheckedItemsCount = int.Parse(row["CheckedItemsCount"].ToString());
                }
                if (row["CompletedPackCount"] != null && row["CompletedPackCount"].ToString() != "")
                {
                    model.CompletedPackCount = int.Parse(row["CompletedPackCount"].ToString());
                }
                if (row["LackedPackCount"] != null && row["LackedPackCount"].ToString() != "")
                {
                    model.LackedPackCount = int.Parse(row["LackedPackCount"].ToString());
                }
                if (row["PanelWeight"] != null && row["PanelWeight"].ToString() != "")
                {
                    model.PanelWeight = Double.Parse(row["PanelWeight"].ToString());
                }
                if (row["FrameWeight"] != null && row["FrameWeight"].ToString() != "")
                {
                    model.FrameWeight = Double.Parse(row["FrameWeight"].ToString());
                }
                if (row["Height"] != null && row["Height"].ToString() != "")
                {
                    model.Height = int.Parse(row["Height"].ToString());
                }
                if (row["NetWeight"] != null && row["NetWeight"].ToString() != "")
                {
                    model.NetWeight = Double.Parse(row["NetWeight"].ToString());
                }
                if (row["GrossWeight"] != null && row["GrossWeight"].ToString() != "")
                {
                    model.GrossWeight = Double.Parse(row["GrossWeight"].ToString());
                }
                if (row["Volume"] != null && row["Volume"].ToString() != "")
                {
                    model.Volume = Double.Parse(row["Volume"].ToString());
                }
                if (row["AssemblyStation"] != null)
                {
                    model.AssemblyStation = row["AssemblyStation"].ToString();
                }
                if (row["SerialNum"] != null)
                {
                    model.SerialNum = row["SerialNum"].ToString();
                }
                if (row["PrintCount"] != null && row["PrintCount"].ToString() != "")
                {
                    model.PrintCount = int.Parse(row["PrintCount"].ToString());
                }
                if (row["PrintEmployeeNum"] != null)
                {
                    model.PrintEmployeeNum = row["PrintEmployeeNum"].ToString();
                }
                if (row["InEmployNum"] != null)
                {
                    model.InEmployNum = row["InEmployNum"].ToString();
                }
                if (row["OutEmployNum"] != null)
                {
                    model.OutEmployNum = row["OutEmployNum"].ToString();
                }
                if (row["State"] != null)
                {
                    model.State = row["State"].ToString();
                }
                if (row["PrintTime"] != null && row["PrintTime"].ToString() != "")
                {
                    model.PrintTime = DateTime.Parse(row["PrintTime"].ToString());
                }
                if (row["InTime"] != null && row["InTime"].ToString() != "")
                {
                    model.InTime = DateTime.Parse(row["InTime"].ToString());
                }
                if (row["OutTime"] != null && row["OutTime"].ToString() != "")
                {
                    model.OutTime = DateTime.Parse(row["OutTime"].ToString());
                }
                if (row["Remark"] != null)
                {
                    model.Remark = row["Remark"].ToString();
                }
            }
            return model;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT Barcode '条码',SubPackNum '包号', BoxId '箱号', OrderSubId  '订单分序号',OrderId '订单号',BoxId '箱号',ProdType '产品类别',SailingDate '船期',Destination '目的地',OutPlanDate '出柜周计划',ProdSpeci '产品名称规格',ProdDesc '产品描述',Addi '附件',FrameColor '框架颜色', LegType '腿类型',MatchedInLeg '配套内腿',FootType '脚类型',PanelSpeci '面板规格',PanelFeature '面板特点',PanelColor '面板颜色',BoardColor '台面颜色',BoardMaterial '台面材质',EdgeColor '封边颜色',BackplaneColor '背板颜色',ChairType '椅壳类型',ChairColor '椅壳颜色',SpecialTagsRemarks '特别标签备注',IncludeItemsFlag '分体配件项数',ItemsPerPack '每包件数',OrderPackCount '订单数量',TotalItemsCount '总件数',CheckedItemsCount '验算件数',CompletedPackCount '完成数量',LackedPackCount '尚缺数量',PanelWeight '面板重量',FrameWeight '框架重量',Height '高度',NetWeight '净重',GrossWeight '毛重',Volume '立方数',AssemblyStation '装配工位',SerialNum '流水号',PrintCount '打印份数',PrintEmployeeNum '打印员工号',InEmployNum '入库员工号',OutEmployNum '出库员工号',State '状态',PrintTime '打印时间',InTime '入库时间',OutTime '出库时间',Remark '备注' ,'修改' '修改','删除' '删除' ");
            strSql.Append(" FROM tb_OPLog ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return SQLHelper.Query(strSql.ToString());
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(OPLogModel Order)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT Barcode '条码',SubPackNum '包号', BoxId '箱号', OrderSubId  '订单分序号',OrderId '订单号',BoxId '箱号',ProdType '产品类别',SailingDate '船期',Destination '目的地',OutPlanDate '出柜周计划',ProdSpeci '产品名称规格',ProdDesc '产品描述',Addi '附件',FrameColor '框架颜色', LegType '腿类型',MatchedInLeg '配套内腿',FootType '脚类型',PanelSpeci '面板规格',PanelFeature '面板特点',PanelColor '面板颜色',BoardColor '台面颜色',BoardMaterial '台面材质',EdgeColor '封边颜色',BackplaneColor '背板颜色',ChairType '椅壳类型',ChairColor '椅壳颜色',SpecialTagsRemarks '特别标签备注',IncludeItemsFlag '分体配件项数',ItemsPerPack '每包件数',OrderPackCount '订单数量',TotalItemsCount '总件数',CheckedItemsCount '验算件数',CompletedPackCount '完成数量',LackedPackCount '尚缺数量',PanelWeight '面板重量',FrameWeight '框架重量',Height '高度',NetWeight '净重',GrossWeight '毛重',Volume '立方数',AssemblyStation '装配工位',SerialNum '流水号',PrintCount '打印份数',PrintEmployeeNum '打印员工号',InEmployNum '入库员工号',OutEmployNum '出库员工号',State '状态',PrintTime '打印时间',InTime '入库时间',OutTime '出库时间',Remark '备注' ,'修改' '修改','删除' '删除' ");
            strSql.Append(" FROM tb_OPLog WHERE 1=1 ");
            if (!string.IsNullOrEmpty(Order.Barcode))
            {
                strSql.Append(" and  Barcode like  '%" + Order.Barcode + "%'");
            }
            if (!string.IsNullOrEmpty(Order.SubPackNum.ToString()))
            {
                strSql.Append(" and  SubPackNum like  '%" + Order.SubPackNum.ToString().Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.BoxId))
            {
                strSql.Append(" and  BoxId like  '%" + Order.BoxId.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.SubPackId))
            {
                strSql.Append(" and  SubPackId like  '%" + Order.SubPackId.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.OrderSubId))
            {
                strSql.Append(" and  OrderSubId like  '%" + Order.OrderSubId.ToString().Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.OrderId))
            {
                strSql.Append(" and  OrderId like  '%" + Order.OrderId.ToString().Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.BoxId))
            {
                strSql.Append(" and  BoxId like  '%" + Order.BoxId.ToString().Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.ProdType))
            {
                strSql.Append(" and  ProdType like  '%" + Order.ProdType.ToString().Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.SailingDate.ToString()))
            {
                strSql.Append(" and  SailingDate like  '%" + Order.SailingDate.ToString().Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.Destination))
            {
                strSql.Append(" and  Destination like  '%" + Order.Destination.ToString().Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.OutPlanDate.ToString()))
            {
                strSql.Append(" and  OutPlanDate like  '%" + Order.OutPlanDate.ToString().Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.ProdSpeci))
            {
                strSql.Append(" and  ProdSpeci like  '%" + Order.ProdSpeci.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.ProdDesc))
            {
                strSql.Append(" and  ProdDesc like  '%" + Order.ProdDesc.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.Addi))
            {
                strSql.Append(" and  Addi like  '%" + Order.Addi.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.FrameColor))
            {
                strSql.Append(" and  FrameColor like  '%" + Order.FrameColor.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.LegType))
            {
                strSql.Append(" and  LegType like  '%" + Order.LegType + "%'");
            }
            if (!string.IsNullOrEmpty(Order.MatchedInLeg))
            {
                strSql.Append(" and  MatchedInLeg like  '%" + Order.MatchedInLeg.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.FootType))
            {
                strSql.Append(" and  FootType like  '%" + Order.FootType.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.PanelSpeci))
            {
                strSql.Append(" and  PanelSpeci like  '%" + Order.PanelSpeci.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.PanelFeature))
            {
                strSql.Append(" and  PanelFeature like  '%" + Order.PanelFeature.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.PanelColor))
            {
                strSql.Append(" and  PanelColor like  '%" + Order.PanelColor.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.BoardColor))
            {
                strSql.Append(" and  BoardColor like  '%" + Order.BoardColor.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.BoardMaterial))
            {
                strSql.Append(" and  BoardMaterial like  '%" + Order.BoardMaterial.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.EdgeColor))
            {
                strSql.Append(" and  EdgeColor like  '%" + Order.EdgeColor + "%'");
            }
            if (!string.IsNullOrEmpty(Order.BackplaneColor))
            {
                strSql.Append(" and  BackplaneColor like  '%" + Order.BackplaneColor.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.ChairType))
            {
                strSql.Append(" and  ChairType like  '%" + Order.ChairType.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.ChairColor))
            {
                strSql.Append(" and  ChairColor like  '%" + Order.ChairColor.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.SpecialTagsRemarks))
            {
                strSql.Append(" and  SpecialTagsRemarks like  '%" + Order.SpecialTagsRemarks.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.IncludeItemsFlag.ToString()))
            {
                strSql.Append(" and  IncludeItemsFlag = " + Order.IncludeItemsFlag.ToString().Trim());
            }
            if (!string.IsNullOrEmpty(Order.ItemsPerPack.ToString()))
            {
                strSql.Append(" and  ItemsPerPack = " + Order.ItemsPerPack.ToString().Trim());
            }
            if (!string.IsNullOrEmpty(Order.OrderPackCount.ToString()))
            {
                strSql.Append(" and  OrderPackCount = " + Order.OrderPackCount.ToString().Trim());
            }
            if (!string.IsNullOrEmpty(Order.TotalItemsCount.ToString()))
            {
                strSql.Append(" and  TotalItemsCount = " + Order.TotalItemsCount.ToString().Trim());
            }
            if (!string.IsNullOrEmpty(Order.CheckedItemsCount.ToString()))
            {
                strSql.Append(" and  CheckedItemsCount = " + Order.CheckedItemsCount.ToString().Trim());
            }
            if (!string.IsNullOrEmpty(Order.CompletedPackCount.ToString()))
            {
                strSql.Append(" and  CompletedPackCount = " + Order.CompletedPackCount.ToString().Trim());
            }
            if (!string.IsNullOrEmpty(Order.LackedPackCount.ToString()))
            {
                strSql.Append(" and  LackedPackCount = " + Order.LackedPackCount.ToString().Trim());
            }
            if (!string.IsNullOrEmpty(Order.PanelWeight.ToString()))
            {
                strSql.Append(" and  PanelWeight = " + Order.PanelWeight.ToString().Trim());
            }
            if (!string.IsNullOrEmpty(Order.FrameWeight.ToString()))
            {
                strSql.Append(" and  FrameWeight = " + Order.FrameWeight.ToString().Trim());
            }
            if (!string.IsNullOrEmpty(Order.Height.ToString()))
            {
                strSql.Append(" and  Height = " + Order.Height.ToString().Trim());
            }
            if (!string.IsNullOrEmpty(Order.NetWeight.ToString()))
            {
                strSql.Append(" and  NetWeight = " + Order.NetWeight.ToString().Trim());
            }
            if (!string.IsNullOrEmpty(Order.GrossWeight.ToString()))
            {
                strSql.Append(" and  GrossWeight = " + Order.GrossWeight.ToString().Trim());
            }
            if (!string.IsNullOrEmpty(Order.Volume.ToString()))
            {
                strSql.Append(" and  Volume = " + Order.Volume.ToString().Trim());
            }
            if (!string.IsNullOrEmpty(Order.AssemblyStation))
            {
                strSql.Append(" and  AssemblyStation like  '%" + Order.AssemblyStation.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.SerialNum))
            {
                strSql.Append(" and  SerialNum like  '%" + Order.SerialNum.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.PrintCount.ToString()))
            {
                strSql.Append(" and  PrintCount like  '%" + Order.PrintCount.ToString().Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.PrintEmployeeNum))
            {
                strSql.Append(" and  PrintEmployeeNum like  '%" + Order.PrintEmployeeNum.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.InEmployNum))
            {
                strSql.Append(" and  InEmployNum like  '%" + Order.InEmployNum.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.OutEmployNum))
            {
                strSql.Append(" and  OutEmployNum like  '%" + Order.OutEmployNum.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.State))
            {
                strSql.Append(" and  State like  '%" + Order.State.Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.PrintTime.ToString()))
            {
                strSql.Append(" and  PrintTime like  '%" + Order.PrintTime.ToString().Trim() + "%'");
            }
            if (!string.IsNullOrEmpty(Order.InTimeBegin.ToString()))
            {
                strSql.Append(" and  InTime >=  '" + Order.InTimeBegin.ToString() + "'");
            }
            if (!string.IsNullOrEmpty(Order.InTimeBegin.ToString()))
            {
                strSql.Append(" and  InTime >=  '" + Order.InTimeBegin.ToString().Trim() + "'");
            }
            if (!string.IsNullOrEmpty(Order.InTimeEnd.ToString()))
            {
                strSql.Append(" and  InTime <=  '" + Order.InTimeEnd.ToString().Trim() + "'");
            }
            if (!string.IsNullOrEmpty(Order.OuttimeBegin.ToString()))
            {
                strSql.Append(" and  OutTime >=  '" + Order.OuttimeBegin.ToString().Trim() + "'");
            }
            if (!string.IsNullOrEmpty(Order.OuttimeEnd.ToString()))
            {
                strSql.Append(" and  OutTime <=  '" + Order.OuttimeEnd.ToString().Trim() + "'");
            }
            if (!string.IsNullOrEmpty(Order.Remark))
            {
                strSql.Append(" and  Remark like  '%" + Order.Remark.Trim() + "%'");
            }

            return SQLHelper.Query(strSql.ToString());
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0)
            {
                strSql.Append(" top " + Top.ToString());
            }
            strSql.Append(" Barcode,SubPackNum,BoxId,OrderSubId,OrderId,ProdType,SailingDate,Destination,OutPlanDate,ProdSpeci,ProdDesc,Addi,FrameColor,LegType,MatchedInLeg,FootType,PanelSpeci,PanelFeature,PanelColor,BoardColor,BoardMaterial,EdgeColor,BackplaneColor,ChairType,ChairColor,SpecialTagsRemarks,IncludeItemsFlag,ItemsPerPack,OrderPackCount,TotalItemsCount,CheckedItemsCount,CompletedPackCount,LackedPackCount,PanelWeight,FrameWeight,Height,NetWeight,GrossWeight,Volume,AssemblyStation,SerialNum,PrintCount,PrintEmployeeNum,InEmployNum,OutEmployNum,State,PrintTime,InTime,OutTime,Remark ");
            strSql.Append(" FROM tb_OPLog ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            return SQLHelper.Query(strSql.ToString());
        }

        /// <summary>
        /// 获取记录总数
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) FROM tb_OPLog ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            object obj = SQLHelper.GetSingle(strSql.ToString());
            if (obj == null)
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("SELECT * FROM ( ");
            strSql.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                strSql.Append("order by T." + orderby);
            }
            else
            {
                strSql.Append("order by T.Barcode desc");
            }
            strSql.Append(")AS Row, T.*  from tb_OPLog T ");
            if (!string.IsNullOrEmpty(strWhere.Trim()))
            {
                strSql.Append(" WHERE " + strWhere);
            }
            strSql.Append(" ) TT");
            strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
            return SQLHelper.Query(strSql.ToString());
        }

        /*
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        {
            SqlParameter[] parameters = {
                    new SqlParameter("@tblName", SqlDbType.VarChar, 255),
                    new SqlParameter("@fldName", SqlDbType.VarChar, 255),
                    new SqlParameter("@PageSize", SqlDbType.Int),
                    new SqlParameter("@PageIndex", SqlDbType.Int),
                    new SqlParameter("@IsReCount", SqlDbType.Bit),
                    new SqlParameter("@OrderType", SqlDbType.Bit),
                    new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
                    };
            parameters[0].Value = "tb_OPLog";
            parameters[1].Value = "Barcode";
            parameters[2].Value = PageSize;
            parameters[3].Value = PageIndex;
            parameters[4].Value = 0;
            parameters[5].Value = 0;
            parameters[6].Value = strWhere;	
            return SQLHelper.RunProcedure("UP_GetRecordByPage",parameters,"ds");
        }*/

        #endregion  BasicMethod

    }
}

